package com.itany.cloud.util;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
@Schema(title = "接口响应的JSON对象")
public class ResponseResult {
    @Schema(title = "业务逻辑状态码")
    private String responseCode;
    @Schema(title = "响应的消息")
    private String message;
    @Schema(title = "响应的数据")
    private Object returnObject;

    public static ResponseResult success() {
        ResponseResult result = new ResponseResult();
        result.setMessage("成功");
        result.setResponseCode("2001");
        return result;
    }

    public static ResponseResult success(String message) {
        ResponseResult result = new ResponseResult();
        result.setMessage(message);
        result.setResponseCode("2001");
        return result;
    }

    public static ResponseResult success(String message,Object returnObject) {
        ResponseResult result = new ResponseResult();
        result.setMessage(message);
        result.setResponseCode("2001");
        result.setReturnObject(returnObject);
        return result;
    }

    public static ResponseResult success(Object returnObject) {
        ResponseResult result = new ResponseResult();
        result.setMessage("成功");
        result.setResponseCode("2001");
        result.setReturnObject(returnObject);
        return result;
    }

    public static ResponseResult fail(String message){
        ResponseResult result = new ResponseResult();
        result.setMessage(message);
        result.setResponseCode("2002");
        return result;
    }
}
